﻿<Window x:Class="XWord.GUI.Views.WordView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WordAssistantApp"
    xmlns:cal="http://www.caliburnproject.org"
    xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
    xmlns:converter="clr-namespace:XWord.GUI.Converters"
    xmlns:fundamental="clr-namespace:XWord.Fundamental;assembly=XWord.Fundamental"
    xmlns:localConverter="clr-namespace:Luna.ApproveSwapModule.Converters"
    Title="让天下没有难记的单词" Height="600" Width="800">
    
    <Window.Resources>
        <converter:PronConverter x:Key="pronConverter"></converter:PronConverter>
        <converter:DictConverter x:Key="dictConverter"></converter:DictConverter>
        <Style x:Key="swapEllipse" TargetType="Ellipse">
            <Setter Property="Width" Value="14"></Setter>
            <Setter Property="Height" Value="14"></Setter>
            <Setter Property="Stroke" Value="Black"></Setter>
            <Setter Property="Margin" Value="5,0,0,0"></Setter>
        </Style>
        <localConverter:BrushStatusConverter x:Key="brushStatusConverter" />
        <localConverter:BrushListenConverter x:Key="brushListenConverter" />
        <localConverter:BrushFrequencyConverter x:Key="brushFrequencyConverter" />
        <localConverter:BrushExpertConverter x:Key="brushExpertConverter" />
        <localConverter:WordConverter x:Key="wordConverter" />
    </Window.Resources>
    <Grid>
        <TabControl HorizontalAlignment="Left" Margin="18,119,0,154" Width="185">
            <TabItem Header="词根树"> 
               <local:EtymaView Width="175" x:Name="etymaView"></local:EtymaView>
            </TabItem>
            <TabItem Header="词根">
                <ListBox Name="etymaListBox" Width="175" ItemsSource="{Binding EtymaList}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Name}"></TextBlock>
                                <TextBlock Margin="10,0,0,0">
                           <Bold>
                            <TextBlock Foreground="Red" Text="{Binding Comment}"></TextBlock>
                        </Bold>
                        </TextBlock>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </TabItem>
            <TabItem Header="分类">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="0.1*"></RowDefinition>
                        <RowDefinition Height="0.9*"></RowDefinition>
                    </Grid.RowDefinitions>


                    <ToolBar Grid.Row="0">
                        <Button Content="关联">
                            <cal:Message.Triggers>
                                <cal:RoutedMessageTriggerCollection>
                                    <cal:EventMessageTrigger EventName="Click">
                                        <cal:EventMessageTrigger.Message>
                                            <cal:ActionMessage MethodName="AssociateCategoryWord">
                                                <cal:Parameter Value="{Binding ElementName=categoryListBox, Path=SelectedItem}" />
                                                <cal:Parameter Value="{Binding ElementName=wordListBox, Path=SelectedItems,Mode=OneWay}" />
                                            </cal:ActionMessage>
                                        </cal:EventMessageTrigger.Message>
                                    </cal:EventMessageTrigger>
                                </cal:RoutedMessageTriggerCollection>
                            </cal:Message.Triggers>
                           </Button>
                        <Button Content="去除">
                            <cal:Message.Triggers>
                                <cal:RoutedMessageTriggerCollection>
                                    <cal:EventMessageTrigger EventName="Click">
                                        <cal:EventMessageTrigger.Message>
                                            <cal:ActionMessage MethodName="UnAssociateCategoryWord">
                                                <cal:Parameter Value="{Binding ElementName=categoryListBox, Path=SelectedItem}" />
                                                <cal:Parameter Value="{Binding ElementName=wordListBox, Path=SelectedItems,Mode=OneWay}" />
                                            </cal:ActionMessage>
                                        </cal:EventMessageTrigger.Message>
                                    </cal:EventMessageTrigger>
                                </cal:RoutedMessageTriggerCollection>
                            </cal:Message.Triggers>
                        </Button>
                        <Button Content="删除" cal:Message.Attach="DeleteCategory(categoryListBox.SelectedItem">
                        </Button>
                    </ToolBar>
                    <ListBox SelectionMode="Multiple"  Grid.Row="1" Name="categoryListBox" Width="175" ItemsSource="{Binding CategoryList}"
                    cal:Message.Attach="[Event SelectionChanged] = [Action FilterCategoryWord($this.SelectedItem)]">
                      
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding Name}"></TextBlock>
                                    <TextBlock Margin="10,0,0,0">
                           <Bold>
                            <TextBlock Foreground="Red" Text="{Binding Comment}"></TextBlock>
                        </Bold>
                        </TextBlock>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </Grid>
            
            </TabItem>
            <TabItem Header="后缀">
                <TabControl>
                    <TabItem Header="名字后缀">
                        <StackPanel>
                            <ListBox Name="nounSuffixListBox" Width="157" Height="223" ItemsSource="{Binding SuffixList}"
                                 cal:Message.Attach="[Event SelectionChanged] = [Action FilterSuffixWord(nounSuffixListBox.SelectedItem)]"    >
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Name}"></TextBlock>
                                            <TextBlock Margin="10,0,0,0">
                           <Bold>
                            <TextBlock Foreground="Red" Text="{Binding Comment}"></TextBlock>
                        </Bold>
                        </TextBlock>
                                        </StackPanel>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </StackPanel>
                    </TabItem>
                </TabControl>
               
            </TabItem>
        </TabControl>
        <Menu Width="111" HorizontalAlignment="Right" Margin="0,121.5,49,0" Height="90" VerticalAlignment="Top">
            <MenuItem Header="高中词汇" x:Name="highShcoolMenu">
                <cal:Message.Triggers>
                    <cal:RoutedMessageTriggerCollection>
                        <cal:EventMessageTrigger EventName="Click">
                            <cal:EventMessageTrigger.Message>
                                <cal:ActionMessage MethodName="MarkIsIgnore">
                                    <cal:Parameter Value="{Binding ElementName=wordListBox, Path=SelectedItems,Mode=OneWay}" />
                                </cal:ActionMessage>
                            </cal:EventMessageTrigger.Message>
                        </cal:EventMessageTrigger>
                    </cal:RoutedMessageTriggerCollection>
                </cal:Message.Triggers>

            </MenuItem>
            <MenuItem Header="听力(要求拼写)" x:Name="xieyin"
                     >
                <cal:Message.Triggers>
                    <cal:RoutedMessageTriggerCollection>
                        <cal:EventMessageTrigger EventName="Click">
                            <cal:EventMessageTrigger.Message>
                                <cal:ActionMessage MethodName="MarkIsFamiliar">
                                    <cal:Parameter Value="{Binding ElementName=wordListBox, Path=SelectedItems,Mode=OneWay}" />
                                </cal:ActionMessage>
                            </cal:EventMessageTrigger.Message>
                        </cal:EventMessageTrigger>
                    </cal:RoutedMessageTriggerCollection>
                </cal:Message.Triggers>
            </MenuItem>
            <!--Click="suffixMenu_Click"-->
            <MenuItem Header="词根" x:Name="suffixMenu" >
                <cal:Message.Triggers>
                    <cal:RoutedMessageTriggerCollection>
                        <cal:EventMessageTrigger EventName="Click">
                            <cal:EventMessageTrigger.Message>
                                <cal:ActionMessage MethodName="ChangeSuffix">
                                    <cal:Parameter Value="{Binding ElementName=wordListBox, Path=SelectedItems,Mode=OneWay}" />
                                </cal:ActionMessage>
                            </cal:EventMessageTrigger.Message>
                        </cal:EventMessageTrigger>
                    </cal:RoutedMessageTriggerCollection>
                </cal:Message.Triggers>
            </MenuItem>
            <MenuItem Header="易忘" x:Name="yiwang">
                <cal:Message.Triggers>
                    <cal:RoutedMessageTriggerCollection>
                        <cal:EventMessageTrigger EventName="Click">
                            <cal:EventMessageTrigger.Message>
                                <cal:ActionMessage MethodName="MarkIsExpert">
                                    <cal:Parameter Value="{Binding ElementName=wordListBox, Path=SelectedItems,Mode=OneWay}" />
                                </cal:ActionMessage>
                            </cal:EventMessageTrigger.Message>
                        </cal:EventMessageTrigger>
                    </cal:RoutedMessageTriggerCollection>
                </cal:Message.Triggers>
            </MenuItem>
            <MenuItem Header="短文阅读" x:Name="yiwang2">
                <cal:Message.Triggers>
                    <cal:RoutedMessageTriggerCollection>
                        <cal:EventMessageTrigger EventName="Click">
                            <cal:EventMessageTrigger.Message>
                                <cal:ActionMessage MethodName="MarkIsShortRead">
                                    <cal:Parameter Value="{Binding ElementName=wordListBox, Path=SelectedItems,Mode=OneWay}" />
                                </cal:ActionMessage>
                            </cal:EventMessageTrigger.Message>
                        </cal:EventMessageTrigger>
                    </cal:RoutedMessageTriggerCollection>
                </cal:Message.Triggers>
            </MenuItem>
        </Menu>
        <ListBox Margin="228,119,174,154" Name="wordListBox" SelectionMode="Multiple" ItemsSource="{Binding WordList}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Expander>
                            <Expander.Header>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding Name}" Margin="0,0,10,0">
                                         <TextBlock.ToolTip>
                            <StackPanel> 
                              <TextBlock Margin="10,0,0,0">
                        <Bold>
                            <TextBlock Foreground="Red" Text="{Binding Comment}"></TextBlock>
                        </Bold>
                    </TextBlock>
                        <WrapPanel>
                            <TextBlock Text="联想:" Foreground="Red"></TextBlock> <TextBlock Text="{Binding ImagineContent}"></TextBlock>         
                        </WrapPanel>
                                  <!--<WrapPanel>
                            <TextBlock Text="来源:" Foreground="Red"></TextBlock><TextBlock  Text="{Binding EtymText}" TextWrapping="Wrap"></TextBlock>         
                        </WrapPanel>-->
                                <WrapPanel>
                            <TextBlock Text="音标:" Foreground="Red"></TextBlock><TextBlock Text="{Binding Pron}"></TextBlock>         
                        </WrapPanel>
                          <WrapPanel>
                            <TextBlock Text="词根:" Foreground="Red"></TextBlock><TextBlock Text="{Binding Suffix}"></TextBlock>         
                        </WrapPanel>
                                 <WrapPanel>
                            <TextBlock Text="拆分:" Foreground="Red"></TextBlock><TextBlock Text="{Binding SeparateWords}"></TextBlock>         
                        </WrapPanel>
                      </StackPanel>
                        </TextBlock.ToolTip>
                       
                    </TextBlock>
                                     <TextBlock Text="{Binding Pron,Converter={StaticResource pronConverter}}" Foreground="{StaticResource {x:Static SystemColors.ActiveBorderBrushKey}}"></TextBlock>
                                     <Button Click="Button_Click">发音</Button>
                            <Ellipse Style="{StaticResource swapEllipse}" ToolTip="高中词汇" Margin="20,0,0,0"
                         cal:Message.Attach="[Event MouseDown] = [Action MarkIsIgnore($this.DataContext)]"
                        
                         Fill="{Binding Path=IsIgnore,Converter={StaticResource brushStatusConverter},Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
                <Ellipse Style="{StaticResource swapEllipse}" ToolTip="高频词汇" Margin="20,0,0,0" 
                         Fill="{Binding Path=IsHighFrequency,Converter={StaticResource brushFrequencyConverter}}" />      
                
                <Ellipse Style="{StaticResource swapEllipse}" ToolTip="听力出现" Margin="20,0,0,0" 
                         Fill="{Binding Path=IsFamiliar,Converter={StaticResource brushListenConverter}}" />
                <Ellipse Style="{StaticResource swapEllipse}" ToolTip="短文出现" Margin="20,0,0,0" 
                         Fill="{Binding Path=IsShortRead,Converter={StaticResource brushListenConverter}}" /> 
                <Ellipse Style="{StaticResource swapEllipse}" ToolTip="易忘词" Margin="20,0,0,0" 
                         Fill="{Binding Path=IsExpert,Converter={StaticResource brushStatusConverter}}" />
                                </StackPanel>
                            </Expander.Header>
                            <Expander.Content>
                                <StackPanel>
                                <!--<ListBox ItemsSource="{Binding Sentences}">
                                    <ListBox.ItemTemplate>
                                        <DataTemplate>
                                            <Border BorderThickness="1">
                                            <StackPanel>
                                                    <TextBlock Text="{Binding Origin}"></TextBlock>
                                                    <TextBlock Text="{Binding Translate}"></TextBlock>
                                                </StackPanel>
                                            </Border>
                                        </DataTemplate>
                                    </ListBox.ItemTemplate>
                                </ListBox>-->
                                    <!--<WebBrowser Loaded="WebBrowser_Loaded"></WebBrowser>-->
                                </StackPanel>
                                <!--<TextBlock Width="350" Text="{Binding EtymText}" TextWrapping="WrapWithOverflow"></TextBlock>-->
                            </Expander.Content>
                        </Expander>
                       
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
           
        </ListBox>
        <TextBox Height="23" Text="{Binding UnKnownWordCount}" HorizontalAlignment="Left" Margin="23,36,0,0" Name="etymaSearchBox" VerticalAlignment="Top" Width="120" />
        <Button Height="23" HorizontalAlignment="Left" Margin="189,35,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click">添加词根</Button>
        <TextBox Height="23" Margin="306,35,352,0" Name="textBox1" VerticalAlignment="Top" 
                 cal:Message.Attach="[Event TextChanged] = [Action SimpleWordSearch($this.Text)]" />
        <CheckBox Height="16" HorizontalAlignment="Left" Margin="228,84,0,0" Name="checkBox1" VerticalAlignment="Top" Width="120" Click="checkBox1_Click">首字匹配</CheckBox>
        <CheckBox Height="16" Margin="317,84,341,0" Name="checkBox2" VerticalAlignment="Top">后缀匹配</CheckBox>

        <Button Height="23" HorizontalAlignment="Right" Margin="0,80.48,140,0" Name="button4" VerticalAlignment="Top" Width="75" cal:Message.Attach="OpenWordSearchDialog">搜索</Button>
        <!--<Button Height="23" HorizontalAlignment="Right" Margin="0,34.48,157,0" Name="button3" VerticalAlignment="Top" Width="75" Click="button3_Click">永久记忆</Button>
        <Button Height="23" HorizontalAlignment="Right" Margin="0,80.48,140,0" Name="button4" VerticalAlignment="Top" Width="75" Click="button4_Click">搜索</Button>
        <Button Height="23" HorizontalAlignment="Right" Margin="0,80.48,59,0" Name="button5" VerticalAlignment="Top" Width="75" cal:Message.Attach="ReflashWordList">刷新</Button>-->
        <Button Height="23" HorizontalAlignment="Left" Margin="128,80.48,0,0" Name="button6" VerticalAlignment="Top" Width="75" Click="button6_Click">复制</Button>
        <TextBox Height="76" Margin="228,0,289,40" Name="textBox2" VerticalAlignment="Bottom" />
        <TextBox Height="47" HorizontalAlignment="Right" Margin="0,0,31,101" Text="{Binding Path=SelectedItem.Suffix, ElementName=wordListBox,UpdateSourceTrigger=PropertyChanged}" 
                 x:Name="wordComment" VerticalAlignment="Bottom" Width="236" />
        <Button Height="23" HorizontalAlignment="Left" Margin="118,0,0,115" Name="button8" VerticalAlignment="Bottom" Width="75"
               cal:Message.Attach="ImportWordList"
               >导入词汇</Button>
        <CheckBox Height="19.48" HorizontalAlignment="Right" Margin="0,84,319,0" Name="checkBox3" VerticalAlignment="Top" Width="67">短文阅读</CheckBox>
        <TextBox Height="23" HorizontalAlignment="Right" Margin="0,0,147,61.48" Name="textBox3" VerticalAlignment="Bottom" Width="120" />
        <Button Height="23" HorizontalAlignment="Left" Margin="23,65,0,0" Name="button9" VerticalAlignment="Top" Width="75" Click="button9_Click">全词根</Button>
        <TextBox Height="23" HorizontalAlignment="Left" Margin="6,90,0,0" Name="textBox4" VerticalAlignment="Top" Width="120" TextChanged="textBox4_TextChanged" />
        <Button Height="23" HorizontalAlignment="Right" Margin="0,35,31,0" Name="button10" VerticalAlignment="Top" Width="93"
                cal:Message.Attach="ImportEtymonList">导入单词词根</Button>
        <Button Height="23" HorizontalAlignment="Right" Margin="0,36,147,0" VerticalAlignment="Top" Width="93"
                cal:Message.Attach="OpenRCArticleDialog">打开阅读理解</Button>
        <Button Content="添加分类"
                cal:Message.Attach="OpenCategoryDialog(categoryListBox.SelectedItem)" 
                Height="23" HorizontalAlignment="Left" Margin="457,36,0,0" Name="button2" VerticalAlignment="Top" Width="75" />
        <Button Content="删除单词"
                
                Height="23" HorizontalAlignment="Left" Margin="474,84,0,0" Name="button3" VerticalAlignment="Top" Width="75">
            <cal:Message.Triggers>
                <cal:RoutedMessageTriggerCollection>
                    <cal:EventMessageTrigger EventName="Click">
                        <cal:EventMessageTrigger.Message>
                            <cal:ActionMessage MethodName="DeleteWord">
                                <cal:Parameter Value="{Binding ElementName=wordListBox, Path=SelectedItems,Mode=OneWay}" />
                            </cal:ActionMessage>
                        </cal:EventMessageTrigger.Message>
                    </cal:EventMessageTrigger>
                </cal:RoutedMessageTriggerCollection>
            </cal:Message.Triggers>
        </Button>
    </Grid>
</Window>
